
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
  # TODO: someone needs to provide the msvc equivalent warning flags
elseif(WIN32)
  # Tareting Windows but using a non-MSVC compiler.  Set -fms-extensions
  # so that we can use __popcnt64
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-fms-extensions>)
else()
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Werror>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wall>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wextra>)

  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Warray-bounds-pointer-arithmetic>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wassign-enum>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Watomic-properties>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wcomma>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wconditional-uninitialized>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wconversion>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wcovered-switch-default>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wdate-time>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wdeprecated>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wdocumentation>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wdouble-promotion>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wduplicate-enum>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wexpansion-to-defined>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wfloat-equal>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Widiomatic-parentheses>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Winfinite-recursion>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wmissing-prototypes>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wnewline-eof>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wnullable-to-nonnull-conversion>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wobjc-interface-ivars>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wover-aligned>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wpacked>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wpointer-arith>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wselector>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wshadow>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wshorten-64-to-32>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wsign-conversion>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wstatic-in-inline>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wsuper-class-method-mismatch>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wswitch>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wunguarded-availability>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wunreachable-code>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wunused>)

  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unknown-warning-option>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-trigraphs>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-four-char-constants>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-disabled-macro-expansion>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-pedantic>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-bad-function-cast>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-c++-compat>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-c++98-compat>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-c++98-compat-pedantic>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-cast-align>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-cast-qual>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-documentation-unknown-command>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-format-nonliteral>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-missing-variable-declarations>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-old-style-cast>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-padded>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-reserved-id-macro>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-shift-sign-overflow>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-undef>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unreachable-code-aggressive>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-macros>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-used-but-marked-unused>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-void-pointer-to-int-cast>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-vla>)

  if(ANDROID)
    add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-incompatible-function-pointer-types>)
    add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-implicit-function-declaration>)
    add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-conversion>)
    add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-int-conversion>)
    add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-shorten-64-to-32>)
  endif()
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-error=assign-enum>)

  # Should re-enable after rdar://133498289 is fixed (ie. fixing the one mismatched cast in apply.c)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-cast-function-type-mismatch>)
  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-Wno-error=unknown-warning-option>)
endif()
